<%- include header %>
<section class="container u_main_box">
    <div class="u_main">
        <!-- 排行 -->
        <div class="u_sort">
                <% if (sort== "popular" || typeof sort == "undefined" || sort == "") { %>
                    <a class="active" href="?sort=popular&page=<%= current_page %>">热门</a>
                <% }else { %>
                    <a  href="?sort=popular&page=<%= current_page %>">热门</a>
                <% } %>
                | 
                <% if (sort== "newest") { %>
                    <a class="active" href="?sort=newest&page=<%= current_page %>">最新</a>
                <% }else{ %>
                    <a href="?sort=newest&page=<%= current_page %>">最新</a>
                <% } %>
        </div>
        <ul class="u_main_ul">
            <% posts.forEach(function (post, index) { %>
            <% if (post.pub == 0 && (user.name!=post.name && user.name != "root")) { %>
                <% if(posts.length == 1){ %>
                <li>
                    对不起，你暂时没有权限查看
                    <span style="padding:0 5px;color:#f60;"><%= post.name %></span>
                    的未公开文章
                </li>
                <% } %>
            <% }else{ %>
                <li>
                    <div class="u_ar_info">
                        <% if (post.pub == 0) { %>
                        <i class="iconfont" style="color: #079194;font-size: 16px;">&#xe657;</i>&nbsp;
                        <% } %>

                        <!-- 文章标签 -->
                        <%- include label %>
                        
                        <a href="/u/<%= post.name %>"><%= post.name %></a>
                        <span><%= post.time.minute %></span>
                        <a href="javascript:;" class="u_ar_read">
                            <i class="iconfont">&#xe661;</i>
                            <%= post.read %>
                        </a>
                        <% if (user && user.name==post.name) { %>
                            <a href="/edit/<%= post._id %>" class="u_edit">·编辑</a>
                            <!-- <a href="/remove/<%= post._id %>" class="u_edit">x删除</a> -->
                        <% } %>
                    </div>
                    <div class="u_ar_title">
                        <a href="/detail/<%= post._id %>"><%= post.title %></a>
                    </div>
                    <!-- <div class="u_ar_info">
                        <a href="javascript:;" class="u_ar_read">
                            <i class="iconfont">&#xe661;</i>
                            阅读 <%= post.read %> 次
                        </a>
                    </div> -->
                </li>
            <% } %>
            
            <% }) %>
        </ul>
        <%- include paging %>
        <% if (!posts.length) {%>
            <div class="u_nodata">
                暂无文章
            </div>
        <% } %>
    </div>
    <div class="u_small">
        <div class="u_about">
            <div class="u_a_t"> 个人成就 </div>
            <div class="u_ar_c">
                <div class="u_ac_top">
                    <div class="u_ac_head">
                            <% if (user) { %>
                                <% if (user.head) { %>
                                    <img  title="<%= user.name %>" src="<%= user.head%>" alt=""> 
                                <% }else{ %>
                                    <img  title="<%= user.name %>" src="/public/img/4965961f1ece63cde79fcf66f9f747c7.png" data-u="<%= user.head%>" alt=""> 
                                <% } %>
                            <% } else { %>
                                <img src=""
                        alt="">
                            <% } %>  
                    </div>
                    <div class="u_ac_ui">
                        <a href="javascript:;" style="margin-bottom:5px;display:inline-block;"><%= user.name %></a>
                        <p>获得点赞 18</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<%- include footer %>
